<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,group-scalable=no"/>
	<title>哈土豆IM管理后台</title>
	<link rel="stylesheet" type="text/css" href="/static/admin/libs/layui/css/layui.css">
	<script src="/static/admin/js/jquery-1.12.4.min.js"></script>
	<script src="/static/admin/libs/layui/layui.js"></script>
	<link rel="stylesheet" type="text/css" href="/static/admin/css/main.css">
	<link rel="stylesheet" type="text/css" href="/static/admin/css/common.css">
</head>

<body>

<div class="members">
	<table class="layui-table" lay-even lay-skin="line">
		<colgroup>
			<col width="150">
			<col width="200">
			<col>
		</colgroup>
		<thead>
		<tr>
			<th>uid</th>
			<th>头像</th>
			<th>账户名</th>
			<th>昵称</th>
			<th>操作</th>
		</tr>
		</thead>
		<tbody>
		{volist name='members' id='item'}
		<tr>
			<td>{$item.uid}</td>
			<td><img src="{$item.avatar}" width="40px"/></td>
			<td>{$item.username}</td>
			<td>{$item.nickname}</td>
			<td uid="{$item.uid}">
				<button class="layui-btn layui-btn-sm layui-btn-warm" pop-event="member_delete">移除</button>
			</td>
		</tr>
		{/volist}
		</tbody>
	</table>

	<div id="page"></div>


	<script>
        layui.use(['laypage', 'layer'], function() {
            var laypage = layui.laypage;
            laypage.render({
                elem: 'page'
				, limit: {$step}
                , count: {$count} //数据总数，从服务端得到
				, curr: {$page}
                , jump: function (obj, first) {
                    //首次不执行
                    if (!first) {
                        //do something
                        location = '/admin/group/members?page='+obj.curr+'&gid={$gid}';
                    }
                }
            });

            $('.members').on("click", "*[pop-event]", function (e) {
                var event = $(this).attr('pop-event');
                callback[event]($(e.target.parentNode).attr('uid'));
            });

            var callback = {
                member_delete:function (uid) {
                    $.ajax({
                        url:'/admin/group/memberdelete',
                        type:'post',
                        data: {gid:{$gid}, uid:uid},
                        success:function(res){
                            if (res.code == 0) {
                                layui.layer.msg('操作成功');
                                setTimeout(function(){location.reload();}, 1000);
                            } else {
                                layui.layer.msg(res.msg);
                            }
                        }
                    });
                }
            }
        });


	</script>
</div>

</body>
</html>


